<template>
  <div class="home">
    <!-- 头部 -->
    <Header/>
    <!-- 疫情热点 -->
    <EpidemicHot :newsInfo="newsInfo" />
    <MyComponent>
      <slot>病毒信息</slot>
    </MyComponent>
    <!-- 病毒信息 -->
    <Covid19Info :dataList="dataList"/>
    <!-- 案例数量 -->
    <CaseNum :caseNumData="caseNumData"/>
    <MyComponent>
      <slot>疫情地图</slot>
    </MyComponent>
    <!-- 全国地图 -->
    <EchartsMap/>
    <!-- 轮播图 -->
    <MySwiper />
    <!-- 疫情期间出行防疫政策 -->
    <PrevPolicy/>
  </div>
</template>

<script>
import { getData } from "@/request/api";
import Header from "@/components/Header";
import Covid19Info from "@/components/Covid19Info";
import CaseNum from "@/components/CaseNum";
import EchartsMap from "@/components/EchartsMap";
import MySwiper from '@/components/MySwiper'
import PrevPolicy from '@/components/PrevPolicy'
import EpidemicHot from '@/components/EpidemicHot'
export default {
  name: "Home",
  components: {
    Header,
    Covid19Info,
    CaseNum,
    EchartsMap,
    MySwiper,
    PrevPolicy,
    EpidemicHot
  },
  data() {
    return {
      dataList: {
        note1: "",
        note2: "",
        note3: "",
        remark1: "",
        remark2: "",
        remark3: ""
      },
      caseNumData: {
        modifyTime: "", //截至目前时间
        currentConfirmedCount: "", //现存确诊人数
        confirmedCount: "", //累计确诊人数
        suspectedCount: "", //累计境外输入人数
        curedCount: "", //累计治愈人数
        deadCount: "", //累计死亡人数
        seriousCount: "", //现存无症状人数
        suspectedIncr: "", //新增境外输入人数
        currentConfirmedIncr: "", //相比昨天现存确诊人数
        confirmedIncr: "", //相比昨天累计确诊人数
        curedIncr: "", //相比昨天新增治愈人数
        deadIncr: "", //相比昨天新增死亡人数
        seriousIncr: "" // 相比昨天现存无症状人数
      },
      newsInfo:[]
    };
  },
  mounted() {
    // 获取疫情数据
    getData({
      key: "a1568fd00063a892bfed027cffd2c452"
    }).then(res => {
      if (res.code === 200) {
        // console.log(res)
        this.dataList.note1 = res.newslist[0].desc.note1;
        this.dataList.note2 = res.newslist[0].desc.note2;
        this.dataList.note3 = res.newslist[0].desc.note3;
        this.dataList.remark1 = res.newslist[0].desc.remark1;
        this.dataList.remark2 = res.newslist[0].desc.remark2;
        this.dataList.remark3 = res.newslist[0].desc.remark3;

        this.caseNumData.modifyTime = res.newslist[0].desc.modifyTime;
        this.caseNumData.currentConfirmedCount =
          res.newslist[0].desc.currentConfirmedCount;
        this.caseNumData.confirmedCount = res.newslist[0].desc.confirmedCount;
        this.caseNumData.suspectedCount = res.newslist[0].desc.suspectedCount;
        this.caseNumData.curedCount = res.newslist[0].desc.curedCount;
        this.caseNumData.deadCount = res.newslist[0].desc.deadCount;
        this.caseNumData.seriousCount = res.newslist[0].desc.seriousCount;
        this.caseNumData.suspectedIncr = res.newslist[0].desc.suspectedIncr;
        this.caseNumData.currentConfirmedIncr =
          res.newslist[0].desc.currentConfirmedIncr;
        this.caseNumData.confirmedIncr = res.newslist[0].desc.confirmedIncr;
        this.caseNumData.curedIncr = res.newslist[0].desc.curedIncr;
        this.caseNumData.deadIncr = res.newslist[0].desc.deadIncr;
        this.caseNumData.seriousIncr = res.newslist[0].desc.seriousIncr;

        // 获取疫情热点数据
        this.newsInfo = res.newslist[0].news;
      }
    });
  }
};
</script>
<style scoped>
</style>
